package com.ssm.gbq.service.impl;

import com.ssm.gbq.dao.DoctorCategoryDao;
import com.ssm.gbq.model.DoctorCategory;
import com.ssm.gbq.service.DoctorCategoryService;
import gbq.ssm.utils.BusinessException;
import gbq.ssm.utils.PageBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DoctorCategoryServiceImpl implements DoctorCategoryService {

    @Autowired
    private DoctorCategoryDao doctorCategoryDao;

    public PageBounds<DoctorCategory> openDoctorCategoryTable(String name, int currentPage, int pageSize) throws Exception {
        try {
            return doctorCategoryDao.openDoctorCategoryTable( name,currentPage, pageSize);
        } catch (Exception e) {
            throw new BusinessException("获取医生列表失败！", e.getMessage());
        }
    }

    public List<DoctorCategory> selectAllDoctorCategory() throws BusinessException {
        try {
            return doctorCategoryDao.selectAllDoctorCategory();
        } catch (Exception e) {
            throw new BusinessException("查询失败！", e.getMessage());

        }
    }

    public void deleteDoctorCategoryByIds(List<Integer> ids) throws BusinessException {
        try {
            doctorCategoryDao.deleteDoctorCategoryByIds(ids);
        } catch (Exception e) {
            throw new BusinessException("删除失败！",e.getMessage());
        }
    }

    public int deleteDoctorCategoryById(Integer id){

        return doctorCategoryDao.deleteDoctorCategoryById(id);
    }

    public int addDoctorCategory(DoctorCategory doctorCategory) throws BusinessException{
        try {
            return doctorCategoryDao.addDoctorCategory(doctorCategory);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 1;
    }

    public int updateDoctorCategory(DoctorCategory doctorCategory) {
        return doctorCategoryDao.updateDoctorCategory(doctorCategory);
    }

}
